fix: localize decimal separator - #2889
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the number-cell renderer in the Tables Vue frontend to format decimal values using the user’s current locale (e.g., comma as decimal separator in de_DE), addressing Issue #1570’s incorrect separator display.
Changes:
- Switch number display formatting from
toFixed()to locale-awareIntl.NumberFormatusing the Nextcloud locale. - Add Cypress component coverage to verify locale-specific decimal separators and fixed decimal precision.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/shared/components/ncTable/partials/TableCellNumber.vue | Formats displayed numeric values using a locale-aware formatter instead of a hardcoded . decimal separator. |
| cypress/component/TableCellNumber.cy.js | Adds component tests validating localized decimal separator output and preserved decimal precision. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| const fractionDigits = Number(this.column?.numberDecimals ?? 0) | ||
| return new Intl.NumberFormat(getCanonicalLocale(), { | ||
| maximumFractionDigits: fractionDigits, | ||
| minimumFractionDigits: fractionDigits, | ||
| useGrouping: false, | ||
| }).format(this.value) |
There was a problem hiding this comment.
Good catch — clamped numberDecimals to the 0..20 integer range Intl.NumberFormat accepts (via Math.trunc + min/max) so out-of-range values no longer throw RangeError when rendering. Added a Cypress case for an oversized decimal count.
There was a problem hiding this comment.
did you actually verify that 0 to 100 fraction digits don't work?
Fixes nextcloud#1570 Clamp fraction digits to the 0..20 range accepted by Intl.NumberFormat so out-of-range column settings cannot throw RangeError while rendering. Signed-off-by: xhon-pelushi <xhon@pelushi.com>
6d33a0c to
aec7e1f
Compare
There was a problem hiding this comment.
do we need to modify NumberForm.vue too?
Use locale-aware decimal separators.
Fixes #1570
Test plan